package com.project.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.project.dto.UserOrderInfoProductEntity;
import lombok.Data;

/**
 * 商品明细表
 */
@Data
@TableName("t_orderInfo")
public class OrderInfoBean {
    /**
     * id
     */
    @TableId(value = "pk_orderInfo",type = IdType.AUTO)
    private Integer id;
    /**
     * 订单Id编号
     */
    @TableField("fk_order")
    private String orderId;
//    /**
//     * 商品明细编号
//     */
//    @TableField("commodityDetailId")
//    private String commodityDetailId;
    /**
     * 大小
     */
    @TableField("size")
    private String size;
    /**
     * 颜色
     */
    @TableField("color")
    private String color;
    /**
     * 商品编号
     */
    @TableField("commodityId")
    private String commodityId;
    /**
     * 商品名
     */
    @TableField("commodityName")
    private String commodityName;
    /**
     * 商品类型
     */
    @TableField("type")
    private String type;
    /**
     * 商品数量
     */
    @TableField("commodityNum")
    private int commodityNum;
    /**
     * 商品价格
     */
    @TableField("commodityPrice")
    private double commodityPrice;

    public OrderInfoBean() {
    }

    public OrderInfoBean(String commodityId, String commodityName, String type, int commodityNum, int commodityPrice) {

        this.commodityId = commodityId;
        this.commodityName = commodityName;
        this.type = type;
        this.commodityNum = commodityNum;
        this.commodityPrice = commodityPrice;
    }

    public static OrderInfoBean fromUserOrderInfoProductEntity(UserOrderInfoProductEntity productEntity) {
        OrderInfoBean orderInfoBean = new OrderInfoBean();
        orderInfoBean.setOrderId(productEntity.getOrderRef());
        orderInfoBean.setCommodityId(productEntity.getProductRef());
        orderInfoBean.setCommodityName(productEntity.getProdcutName());
        orderInfoBean.setCommodityNum(productEntity.getProductNumber());
        orderInfoBean.setCommodityPrice((productEntity.getProductPrice() * 100));
        orderInfoBean.setColor(productEntity.getColor());
        orderInfoBean.setType(productEntity.getType());
        return orderInfoBean;
    }
}
